set(L_SML_LIB sml)

file(GLOB_RECURSE SOURCES "*.cpp")
add_library(${L_SML_LIB} SHARED ${SOURCES})

if(CONAN_DEFS_SML_OPEN)
    target_include_directories(${L_SML_LIB}
        PUBLIC ${PROJECT_SOURCE_DIR}/src/lualib-src/sml/smlib
        PUBLIC ${PROJECT_SOURCE_DIR}/src/lualib-src/sml/sml_base/inc
        PUBLIC ${PROJECT_SOURCE_DIR}/src/lualib-src/sml/platform
        PUBLIC ${PROJECT_SOURCE_DIR}/src/lualib-src/sml/pd_log_parse/inc
    )
else()
    target_include_directories(${L_SML_LIB}
        PUBLIC ${libmgmt_protocol_INCLUDE_DIRS}
    )
endif()

if(CONAN_DEFS_SML_OPEN)
    target_link_libraries(${L_SML_LIB}
        PUBLIC platform_open
    )
else()
    target_link_libraries(${L_SML_LIB}
        PUBLIC libmgmt_protocol::libplatform
    )
endif()

target_include_directories(${L_SML_LIB}
    PUBLIC ${LUACLIB_SRC_DIR}
    PUBLIC ${CONAN_INCLUDE_DIRS}
    PUBLIC ${GLIB_INCLUDE_DIRS}
)
target_link_libraries(${L_SML_LIB}
    PUBLIC ${GLIB_LIBRARIES}
    PUBLIC ${CONAN_LIBS_HUAWEI_SECURE_C}
    PUBLIC ${GLIB2_LIBRARIES}
    PUBLIC libmc4lua::libmc4lua
    PUBLIC huawei_secure_c::huawei_secure_c
    PUBLIC skynet::skynet
    PUBLIC json::json
    PUBLIC liblogger::liblogger
)

set_target_properties(${L_SML_LIB} PROPERTIES PREFIX "")
install(TARGETS ${L_SML_LIB} DESTINATION opt/bmc/luaclib)
